//
//  AlarmMessageDetailViewController.m
//  SIPphone
//
//  Created by wrt on 14-2-20.
//  Copyright (c) 2014年 wrtsoft. All rights reserved.
//

#import "AlarmMessageDetailViewController.h"
#import "AlarmControlViewController.h"

@interface AlarmMessageDetailViewController ()
{
    int tempType;
    NSString *tempAlarmUri;
    NSString *tempPublishUri;
    NSString *tempStartTime;
    NSString *tempEndTime;
    NSString *tempResult;
    NSString *tempRmark;
    int tempTomanager;
}
@end

@implementation AlarmMessageDetailViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (id)initWithAlarmType:(int)type andAlarmURI:(NSString *)alarmUri andPublishURI:(NSString *)publishUri andStartTime:(NSString *)startTime andEndTime:(NSString *)endTime andResult:(NSString *)result andRemark:(NSString *)remark andTomanager:(int)tomanager
{
    self = [super init];
    if (self)
    {
        tempType = type;
        tempAlarmUri = [[NSString alloc] init];
        tempPublishUri = [[NSString alloc] init];
        tempStartTime = [[NSString alloc] init];
        tempEndTime = [[NSString alloc] init];
        tempResult = [[NSString alloc] init];
        tempRmark = [[NSString alloc] init];
        tempAlarmUri = alarmUri;
        tempPublishUri = publishUri;
        tempStartTime = startTime;
        tempEndTime = endTime;
        tempResult = result;
        tempRmark = remark;
       tempTomanager = tomanager;
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self.scrollView setScrollEnabled:YES];
    CGRect r = [ UIScreen mainScreen ].applicationFrame;
    [self.scrollView setContentSize:CGSizeMake(320, r.size.height - 92)];
    
    switch (tempType)
    {
        case 1:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"fire", @"火灾 Fire"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"fire", @"火灾 Fire"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            break;
        case 2:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"gas", @"瓦斯 Gas"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"gas", @"瓦斯 Gas"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            break;
        case 3:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"infrared", @"红外线 Infrared"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"infrared", @"红外线 Infrared"),NSLocalizedString(@"alarm", @"报警 Alarm")];            break;
        case 4:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"magnetic", @"门磁 Magnetic"),NSLocalizedString(@"alarm", @"报警 Alarm")];            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"magnetic", @"门磁 Magnetic"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            break;
        case 5:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"zone5", @"防区5 Zone 5"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"zone5", @"防区5 Zone 5"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            break;
        case 6:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"zone6", @"防区6 Zone 6"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"zone6", @"防区6 Zone 6"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            break;
        case 7:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"zone7", @"防区7 Zone 7"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"zone7", @"防区7 Zone 7"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            break;
        case 8:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"zone8", @"防区8 Zone 8"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"zone8", @"防区8 Zone 8"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            break;
        case 9:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"tamper", @"防拆 Tamper"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"tamper", @"防拆 Tamper"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            break;
        case 10:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"illegaldoor", @"非法开门 Illegal door"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"illegaldoor", @"非法开门 Illegal door"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            break;
        case 11:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"stressdoor", @"胁迫开门 Stress door"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"stressdoor", @"胁迫开门 Stress door"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            break;
        case 12:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"hostMagnetic", @"主机门磁 Host Magnetic"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"hostMagnetic", @"主机门磁 Host Magnetic"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            break;
        case 13:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"undervoltage", @"欠压 Undervoltage"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"undervoltage", @"欠压 Undervoltage"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            break;
        case 14:
            self.title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"voltage returns to normal", @"电压恢复正常 Voltage returns to normal")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@",NSLocalizedString(@"voltage returns to normal", @"电压恢复正常 Voltage returns to normal")];
            break;
        case 15:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"arming", @"布防 Arming"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"arming", @"布防 Arming"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            break;
        case 16:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"disarming", @"撤防 Disarming"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"disarming", @"撤防 Disarming"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            break;
        case 17:
            self.title = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"batch", @"批处理 Batch"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            self.typeLabel.text = [NSString stringWithFormat:@"%@%@",NSLocalizedString(@"batch", @"批处理 Batch"),NSLocalizedString(@"alarm", @"报警 Alarm")];
            break;
            
            
        default:
            break;
    }
    
    self.alarmUriLabel.text = tempAlarmUri;
    self.publishUriLabel.text = tempPublishUri;
    self.startTimeLabel.text = tempStartTime;
    self.endTimeLabel.text = tempEndTime;
    if ([tempResult isEqualToString:@"(null)"])
    {
        self.resultLabel.text = NSLocalizedString(@"NO", @"无 NO");
    }
    else
    {
        self.resultLabel.text = tempResult;
    }
    
    if ([tempRmark isEqualToString:@"(null)"])
    {
        self.remarkLabel.text = NSLocalizedString(@"NO", @"无 NO");
    }
    else
    {
        self.remarkLabel.text = tempRmark;
    }
    
    
    
    switch (tempTomanager)
    {
        case 0:
            self.toManagerLabel.text = NSLocalizedString(@"unreported", @"不报告 Unreported");
            break;
        case 1:
            self.toManagerLabel.text = NSLocalizedString(@"report", @"报告 Report");
            break;
        case 2:
            self.toManagerLabel.text = NSLocalizedString(@"both reported", @"两者同时报 Both reported");
            break;
        default:
            break;
    }
    
    //防区控制按钮
    UIBarButtonItem *alarmControlButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"zone Control", @"防区控制 Zone Controlend") style:UIBarButtonItemStyleBordered target:self action:@selector(alarmControlButtonPressed)];
    self.navigationItem.rightBarButtonItem = alarmControlButton;
    
}

- (void)alarmControlButtonPressed
{
    AlarmControlViewController *alarmControlVC = [[AlarmControlViewController alloc] init];
    [self.navigationController pushViewController:alarmControlVC animated:YES];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
